package validator

import "regexp"

type passwordType struct {
}

var passwordReg = regexp.MustCompile("^[0-9A-z.,<>/?*&^%$#@!~+-;:'\"()]{5,}$")

func (p *passwordType) Validate(name string, val string, required bool) (bool, string) {
	if val == "" {
		if required {
			return false, name + "不能为空"
		}
		return true, ""
	}

	if !passwordReg.MatchString(val) {
		return false, name + "填写有误, 应为：字母+数字+英文符号组合, 不小于5位"
	}
	return true, ""
}
